package com.blueocean_health.care.management.controller;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.blueocean_health.care.management.common.LocalManager;
import com.blueocean_health.care.management.domain.base.SysResult;
import com.blueocean_health.care.management.em.LocalManagerType;
import com.blueocean_health.care.management.service.ScheduleHome;
import com.blueocean_health.care.management.service.TestService;

@RestController
@RequestMapping(value = "/test", produces = MediaType.APPLICATION_JSON_VALUE)
public class TestController {
	 private Logger logger = Logger.getLogger(TestController.class);  
	@Autowired
	private TestService testService;
	@Autowired
	private ScheduleHome scheduleHome;
	@RequestMapping("/hello")
	public String hello(){
		scheduleHome.schedule();
		  logger.info("this is info");
		  logger.debug("this is debug");
		  logger.error("this is error");
		return "helloWorld";
	}
	
	@RequestMapping("/hello2")
	public SysResult hello2(Integer id){
		return testService.hello(id).addData(LocalManager.getVal(LocalManagerType.IP));
	}

	
	@RequestMapping("/hello3/{id}")
	public SysResult hello3(@PathVariable Integer id){
		//返回对应ID的姓名, 并且data中加入了IP地址
		return testService.hello(id).addData(LocalManager.getVal(LocalManagerType.IP));
	}
	
}
